package com.times.core.base;

/**
 * ajax返回实体
 */
public class BaseResult {

     // 状态码：200, 400, 403, 500等
    public int code;

    // 成功为success，其他为失败原因
    public String message;

    // 数据结果集
    public Object data;

    public BaseResult(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * 操作成功，只返回操作码
     * @return
     */
    public static BaseResult optSuccess(){
        BaseResult result = new BaseResult(200, "", null);
        result.code = 200;
        return result;
    }

    /**
     * 操作成功并返回数据
     * @param obj
     * @return
     */
    public static BaseResult optSuccessWithData(Object obj){
        BaseResult result = new BaseResult(200, "", obj);
        result.code = 200;
        return result;
    }



    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
